package main

import "fmt"

func main()  {
	/*
	fallthrough，用于穿透switch
	 */
	 //练习2：给定月份，输出该月的天数。
	 month := 4
	 day := 0
	switch month {
	case 1, 3, 5, 7, 8, 10, 12:
		day = 31
	case 4,6,9,11:
		day =30
	case 2:
		//判断是否是闰年
		day = 28
	}
	fmt.Println(day)

	a := 2
	switch a {
	case 1:
		fmt.Println("第一季度")
		fallthrough // 穿透该case，下一个case不需要判断，直接执行
	case 2:
		fmt.Println("第二季度")
		fallthrough
	case 3:
		fmt.Println("第三季度")
		fallthrough
	case 4:
		fmt.Println("第四季度")
	}

	//练习1：
	month2 := 4
	day2 := 0
	switch month2 {
	case 1:
		fallthrough
	case 3:
		fallthrough
	case 5:
		fallthrough
	case 7:
		fallthrough
	case 8:
		fallthrough
	case 10:
		fallthrough
	case 12:
		day2 = 31
	case 4:
		fallthrough
	case 6:
		fallthrough
	case 9:
		fallthrough
	case 11:
		day2 = 30
	case 2:
		day2 = 28
	}
	fmt.Println(day2)
}
